\begin{algorithm}[H]
    \renewcommand{\algorithmicrequire}{\textbf{Input:}}
	\renewcommand{\algorithmicensure}{\textbf{Output:}}
	\caption{Generation of granular balls}
    \label{al:geneball}
    \begin{algorithmic}[1] % 控制是否有序号
        \Require Data Set $D$ , The Purity Threshold $p$  ; % input 的内容
	    \Ensure The granular balls; % output 的内容
        \State Inplement the 2-means clustering algorithm on $D$ and generate two granular balls $D_1^i$ and $D_2^i$ ,
        where $i$ is initialized as $1$ , and it denotes the iteration number;
        \For{each $D_j^i$ }\label{al:st2}
            \State The center of $D_j^i$ is the center of gravity of all sample points in it; 
            \State The radius of $D_j^i$ is equal to the average value of distance from all samples in $D_j^i$ to its center;
            \State The purity degrees $PD_j^i$ is equal to the percentage of majority samples in $D_j^i$ ;
            \If{ $PD_j^i$ is lower than $p$ }
                \State Split $D_j^i$ by appliying the 2-means clustering algorithm on it;
            \EndIf 
        \EndFor 
        \If{the purity degree of each granular ball is higher than $p$ }
            \State \textbf{return} Granular balls.
        \Else 
            \State i = i + 1;
            \State Go to step \ref{al:st2}
        \EndIf
    \end{algorithmic}
\end{algorithm}